<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Model extends CIC_A_Controller
{
	function __construct()
	{
		parent::__construct();
	}
	function index()
	{
		$this->admin_priv(__METHOD__);
		$data['model'] = $this->cic_model->get_all('model','',array('model_sort','asc'));
		$this->load->view('admin/model/index',$data);
	}
	function model_add()
	{
		$this->load->view('admin/model/model_add');
	}
	function add_model()
	{
		$this->admin_priv(__METHOD__);
		if($this->input->post('submit'))
		{
			$this->validate('model', 'admin/model/model_add');
			$data = array(
					'model_name'		=> $this->input->post('model_name'),
					'model_table_name'	=> $this->input->post('model_table_name'),
					'list_tpl'			=> $this->input->post('model_list_tpl'),
					'content_tpl'			=> $this->input->post('model_content_tpl'),
					'model_sort'			=> $this->input->post('model_sort'),		
			);
			if($this->cic_model->insert('model',$data))
				$this->message->msg('添加成功！',site_url('admin/model/index'));
			else
				$this->message->msg('添加失败！',site_url('admin/model/model_add'));
		}
	}
}